﻿<Window x:Class="AgilePairingBacklog.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:AgilePairingBacklog"
        xmlns:models="clr-namespace:AgilePairingBacklog.Models"
        Title="Agile Pairing Backlog"
        DataContext="{Binding RelativeSource={RelativeSource Self}, Path=BacklogProject}">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.New" Executed="ExecuteNewCommand"/>
        <CommandBinding Command="models:ApplicationCommandsEx.EnterEditMode" Executed="ExecuteEnterEditModeCommand"/>
        <CommandBinding Command="models:ApplicationCommandsEx.ExitEditMode" Executed="ExecuteExitEditModeCommand"/>
    </Window.CommandBindings>
    <Window.Resources>
        <Style TargetType="{x:Type ListBoxItem}" x:Key="EditableListBoxItem">

        </Style>
        <DataTemplate DataType="{x:Type models:Person}">
            <DataTemplate.Triggers>
                <Trigger SourceName="Root" Property="local:MainWindow.IsInEditMode" Value="true">
                    <Setter TargetName="NameTextBlock" Property="TextBox.Visibility" Value="Collapsed"/>
                    <Setter TargetName="NameTextBox" Property="TextBox.Visibility" Value="Visible"/>
                    <Setter TargetName="RoleTextBlock" Property="TextBox.Visibility" Value="Collapsed"/>
                    <Setter TargetName="RoleTextBox" Property="TextBox.Visibility" Value="Visible"/>
                </Trigger>
                <Trigger SourceName="Root" Property="local:MainWindow.IsInEditMode" Value="false">
                    <Setter TargetName="NameTextBlock" Property="TextBox.Visibility" Value="Visible"/>
                    <Setter TargetName="NameTextBox" Property="TextBox.Visibility" Value="Collapsed"/>
                    <Setter TargetName="RoleTextBlock" Property="TextBox.Visibility" Value="Visible"/>
                    <Setter TargetName="RoleTextBox" Property="TextBox.Visibility" Value="Collapsed"/>
                </Trigger>
            </DataTemplate.Triggers>
            <Border x:Name="Root">
                <Border.InputBindings>
                    <MouseBinding MouseAction="LeftDoubleClick" Command="models:ApplicationCommandsEx.EnterEditMode"/>
                </Border.InputBindings>
                <Grid Margin="5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" BorderThickness="2" BorderBrush="Black" CornerRadius="2">
                        <Image Source="Content/person.png"/>
                    </Border>
                    <TextBlock x:Name="NameTextBlock" Grid.Row="0" Grid.Column="1" FontSize="20" Padding="5,0,0,0" Text="{Binding Name}"/>
                    <TextBox x:Name="NameTextBox" Grid.Row="0" Grid.Column="1" FontSize="20" Padding="5,0,0,0" Text="{Binding Name}"/>
                    <TextBlock x:Name="RoleTextBlock" Grid.Row="1" Grid.Column="1" FontStyle="Italic" Padding="5,0,0,0" Text="{Binding Role}"/>
                    <TextBox x:Name="RoleTextBox" Grid.Row="1" Grid.Column="1" FontStyle="Italic" Padding="5,0,0,0" Text="{Binding Role}"/>
                </Grid>
            </Border>    
        </DataTemplate>
        <DataTemplate DataType="{x:Type models:Task}">
            <Border x:Name="TaskRow" Padding="20">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Grid.Column="0" FontFamily="Cambria" FontSize="20" Text="{Binding Path=Name}" TextWrapping="Wrap" AcceptsReturn="True" Background="Transparent" BorderThickness="0"/>
                    <ItemsControl Grid.Column="1" ItemsSource="{Binding Path=Pairings}" Margin="10,0,0,0">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>
                </Grid>
            </Border>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Status}" Value="Completed">
                    <Setter Property="Background" Value="LightGreen" TargetName="TaskRow"/>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
        <DataTemplate DataType="{x:Type models:Pairing}">
            <Border Width="180" Height="150" CornerRadius="2" BorderBrush="Black" BorderThickness="1" Padding="3" TextElement.FontFamily="Lucida Handwriting" TextElement.FontSize="20" >
                <Border.RenderTransform>
                    <RotateTransform Angle="3"/>
                </Border.RenderTransform>
                <Border.Background>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="PaleGoldenrod" Offset="0.0" />
                        <GradientStop Color="PaleGoldenrod" Offset="0.25" />
                        <GradientStop Color="LightGoldenrodYellow" Offset="0.75" />
                        <GradientStop Color="LemonChiffon" Offset="1.0" />
                    </LinearGradientBrush>
                </Border.Background>
                <Border.Effect>
                    <DropShadowEffect Color="Black" Direction="320" ShadowDepth="8" BlurRadius="5" Opacity="0.5" />
                </Border.Effect>
                <StackPanel Margin="0,20,0,0" HorizontalAlignment="Center">
                    <TextBlock Text="{Binding Path=FirstPerson.Name}" HorizontalAlignment="Center"/>
                    <TextBlock Text="+" HorizontalAlignment="Center"/>
                    <TextBlock Text="{Binding Path=SecondPerson.Name}" HorizontalAlignment="Center"/>
                </StackPanel>
            </Border>
        </DataTemplate>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Menu Grid.Row="0">
            <MenuItem Header="_File">
                <MenuItem Header="_New" Command="ApplicationCommands.New"/>
                <MenuItem Header="_Open..." Command="ApplicationCommands.Open"/>
                <MenuItem Header="_Save" Command="ApplicationCommands.Save"/>
                <MenuItem Header="_SaveAs" Command="ApplicationCommands.SaveAs"/>
                <Separator/>
                <MenuItem Header="_Exit" Command="models:ApplicationCommandsEx.Exit"/>
            </MenuItem>
            <MenuItem Header="_View">
                <MenuItem Header="_Team" Command="models:ApplicationCommandsEx.ViewTeam"/>
                <MenuItem Header="_Board">
                    <MenuItem Header="_People" Command="models:ApplicationCommandsEx.ViewPeopleBoard"/>
                    <MenuItem Header="_Tasks" Command="models:ApplicationCommandsEx.ViewTasksBoard"/>
                </MenuItem>
            </MenuItem>
        </Menu>
        <TabControl Grid.Row="1">
            <TabItem Header="Team">
                <DockPanel>
                    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
                        <Button Width="40" Height="40" Content="New"/>
                        <Button Width="40" Height="40" Content="Delete"/>
                    </StackPanel>
                    <ListBox ItemsSource="{Binding Path=TeamMembers}" HorizontalContentAlignment="Stretch"/>
                </DockPanel>
            </TabItem>
            <TabItem Header="Backlog">
                
            </TabItem>
            <TabItem Header="Pairing">
                <ListBox ItemsSource="{Binding Path=Tasks}" VirtualizingPanel.ScrollUnit="Pixel" HorizontalContentAlignment="Stretch"/>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
